package com.googlecode.jsqlconverter.filter;

import java.util.logging.Logger;

import com.googlecode.jsqlconverter.definition.Statement;
import com.googlecode.jsqlconverter.definition.create.index.CreateIndex;
import com.googlecode.jsqlconverter.definition.create.table.CreateTable;
import com.googlecode.jsqlconverter.definition.insert.InsertFromValues;
import com.googlecode.jsqlconverter.definition.truncate.table.Truncate;
import com.googlecode.jsqlconverter.filter.interfaces.TransformIndex;
import com.googlecode.jsqlconverter.filter.interfaces.TransformInsertFromValues;
import com.googlecode.jsqlconverter.filter.interfaces.TransformTable;
import com.googlecode.jsqlconverter.filter.interfaces.TransformTruncate;

public abstract class Filter {
	protected static final Logger LOG = Logger.getLogger(Filter.class.getName());

	public final Statement filter(Statement statement)  {
		if (statement instanceof CreateIndex && this instanceof TransformIndex) 
			return ((TransformIndex)this).transform((CreateIndex)statement);
		if (statement instanceof CreateTable && this instanceof TransformTable)
			return ((TransformTable)this).transform((CreateTable)statement);
		if (statement instanceof Truncate && this instanceof TransformTruncate)
			return ((TransformTruncate)this).transform((Truncate)statement);
		if (statement instanceof InsertFromValues && this instanceof TransformInsertFromValues)
			return ((TransformInsertFromValues)this).transform((InsertFromValues)statement);
		
		return statement;
	}
}
